﻿@page "/"

@inject HttpClient HttpClient

<BlazePage Title="Dashboard">
    <MudGrid>
        <MudItem xs="12"
                 sm="6"
                 lg="3">
            <BlazeSummary Content="@_productsCount.ToString("N0")"
                          Description="Products"
                          DisplayColor="--mud-palette-primary"
                          Icon="@Icons.Material.Rounded.Widgets"/>
        </MudItem>
        <MudItem xs="12" sm="6" lg="3">
            <BlazeSummary Content="400"
                          Description="Sales"
                          DisplayColor="--mud-palette-secondary"
                          Icon="@Icons.Material.Rounded.CurrencyExchange"/>
        </MudItem>
        <MudItem xs="12" sm="6" lg="3">
            <BlazeSummary Content="400"
                          Description="Sales"
                          DisplayColor="--mud-palette-tertiary"
                          Icon="@Icons.Material.Rounded.BarChart"/>
        </MudItem>
        <MudItem xs="12" sm="6" lg="3">
            <BlazeSummary Content="400"
                          Description="Sales"
                          DisplayColor="--mud-palette-info"
                          Icon="@Icons.Material.Rounded.CurrencyExchange"/>
        </MudItem>
        <MudItem xs="12" sm="6">
            <MudGrid>
                <MudItem xs="12">
                    <MudPaper Elevation="0"
                              Class="pa-4 rounded-lg h-[200px]">
                    </MudPaper>
                </MudItem>
                <MudItem xs="12">
                    <MudPaper Elevation="0"
                              Class="pa-4 rounded-lg h-[200px]">
                    </MudPaper>
                </MudItem>
            </MudGrid>
        </MudItem>
        <MudItem xs="12" sm="6">
            <MudPaper Elevation="0"
                      Class="pa-4 rounded-lg h-full">
            </MudPaper>
        </MudItem>
        <MudItem xs="12" sm="6" md="4">
            <MudPaper Elevation="0"
                      Class="pa-4 rounded-lg h-[200px]">
            </MudPaper>
        </MudItem>
        <MudItem xs="12" sm="6" md="4">
            <MudPaper Elevation="0"
                      Class="pa-4 rounded-lg h-[200px]">
            </MudPaper>
        </MudItem>
        <MudItem xs="12" sm="12" md="4">
            <MudPaper Elevation="0"
                      Class="pa-4 rounded-lg h-[200px]">

            </MudPaper>
        </MudItem>
    </MudGrid>
</BlazePage>


@code {

    private int _productsCount;

    protected override async Task OnInitializedAsync()
    {
        _productsCount = await HttpClient.GetFromJsonAsync<int>("api/products/count-all");
        await InvokeAsync(StateHasChanged);
    }

}